﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CastleOfTheDisillusioned {
	class BoundingBox {
		public virtual double X { get; set; }
		public virtual double Y { get; set; }
		public virtual double Width { get; set; }
		public virtual double Height { get; set; }

		public double Left {
			get {
				return X;
			}
		}

		public double Right {
			get {
				return X + Width;
			}
		}

		public double Top {
			get {
				return Y;
			}
		}

		public double Bottom {
			get {
				return Y + Height;
			}
		}

		public BoundingBox() {
			X = 0;
			Y = 0;
			Width = 0;
			Height = 0;
		}

		public BoundingBox(double x, double y, double width, double height) {
			X = x;
			Y = y;
			Width = width;
			Height = height;
		}

		public virtual bool CollidesWith(BoundingBox B) {
			BoundingBox A = this;
			if (A.Left >= B.Right) return false;
			if (A.Right <= B.Left) return false;
			if (A.Top >= B.Bottom) return false;
			if (A.Bottom <= B.Top) return false;

			return true;
		}

		public BoundingBox Copy() {
			return new BoundingBox(X, Y, Width, Height);
		}
	}
}